//
//  JCEnumDescription.m
//  JCSDK
//
//  Created by master on 16/2/23.
//  Copyright © 2016年 AdMaster. All rights reserved.
//

#import "JCEnumDescription.h"

@interface JCEnumDescription ()

{
    NSMutableDictionary *_values;
}

@end

@implementation JCEnumDescription

- (instancetype)initWithDictionary:(NSDictionary *)dictionary {
    if(self = [super initWithDictionary:dictionary]) {
        
        _base_type = dictionary[@"base_type"];
        _flag_set = dictionary[@"flag_set"];
        NSArray *values = dictionary[@"values"];
        NSParameterAssert(_base_type != nil);
        NSParameterAssert(_flag_set != nil);
        NSParameterAssert(values != nil);


        if([values isKindOfClass:[NSArray class]]) {
            _values = [NSMutableDictionary dictionaryWithCapacity:values.count];
            for(NSDictionary *dict in values) {
                if([dict isKindOfClass:[NSDictionary class]]) {
                    [_values setValue:dict[@"display_name"] forKey:dict[@"value"]];
                }
            }

        }
    }
    return  self;
}

- (NSArray *)allValues
{
    return [_values allKeys];
}

@end

